<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Statement" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>录入成功</title>
    <meta http-equiv="refresh" content="2;URL=http://localhost:8080/userList.jsp">
</head>
<body>
<h1>成功！！正在跳转页面到用户列表...</h1>
<%

    // 一、获得用户输入的信息
    String name = request.getParameter("username");
    String password = request.getParameter("password");

    // 二、3+1 将用户信息写入到数据库
    Connection connection = null;
    Statement statement = null;

    // t_users
    String sql = "insert into t_users(username,password) values('"+name+"', '"+password+"')";

    Class.forName("com.mysql.jdbc.Driver");

    connection = DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/sctu_javaweb_2018?serverTimezone=UTC",
            "root",
            "123456"
    );

    statement = connection.createStatement();
    statement.execute(sql);

    statement.close();
    connection.close();

%>
</body>
</html>
